import time
def readlist(name):
    file = open(name,'r')
    data = file.readlines()
    return data

def bublesort(filename,n):
    for j in range(n - 1):
        for i in range(n - j - 1):
            if filename[i] > filename[i + 1]:
                filename[i], filename[i+1] = filename[i+1], filename[i]

a1 = readlist('m1_sorted.txt')
size1 = len(a1)
t_start = time.time() 
bublesort(a1,size1)
t_finish = time.time()
print('Масив m1_sorted.txt отсортирован за', round((t_finish - t_start)*1000), 'милисекунд')

a2 = readlist('m2_reverse.txt')
size2 = len(a2)
time1 = time.time()
bublesort(a2,size2)
time2 = time.time()
print('Масив m2_reverse.txt отсортирован за', round((time2 - time1)*1000), 'милисекунд')


a3 = readlist('m3_shuffle.txt')
size3 = len(a3)
time1 = time.time()
bublesort(a3,size3)
time2 = time.time()
print('Масив m3_shuffle.txt отсортирован за', round((time2 - time1) * 1000), 'милисекунд')


